<template>
  <div>
    <div>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/welcome3' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item :to="{ path: $route.path }">{{ $route.meta.title }}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>

      <!--  搜索-->
      <el-input v-model="search1" placeholder="请输入学校标识码" style="width: 12%;margin-left: 10px;margin-top: 10px" size="mini"></el-input>
      <el-input v-model="search2" placeholder="请输入学校名称" style="width: 12%;margin-left: 10px" size="mini"></el-input>
      <el-input v-model="search3" placeholder="请输入学校地址名称" style="width: 12%;margin-left: 10px" size="mini"></el-input>
    <el-select v-model="search4" placeholder="请选择驻地城乡类型" size="mini" style="margin-left: 10px">
      <el-option
          v-for="item in locationtypenameoptions"
          :key="item.value"
          :label="item.label"
          :value="item.label">
      </el-option>
    </el-select>
    <el-select v-model="search5" placeholder="请选择办学类型" size="mini" style="margin-left: 10px">
      <el-option
          v-for="item in typenameoptions"
          :key="item.value"
          :label="item.label"
          :value="item.label">
      </el-option>
    </el-select>
    <el-select v-model="search6" placeholder="请选择举办者" size="mini" style="margin-left: 10px">
      <el-option
          v-for="item in hostnameoptions"
          :key="item.value"
          :label="item.label"
          :value="item.label">
      </el-option>
    </el-select>
<!--      <el-input v-model="search4" placeholder="请输入驻地城乡类型代码或名称" style="width: 12%;margin-left: 10px" size="mini"></el-input>-->
<!--      <el-input v-model="search5" placeholder="请输入办学类型代码或名称" style="width: 12%;margin-left: 10px" size="mini"></el-input>-->
<!--      <el-input v-model="search6" placeholder="请输入举办者代码或名称" style="width: 12%;margin-left: 10px" size="mini"></el-input>-->
      <el-button type="primary" style="margin-top: 10px;margin-left: 10px;width: 160px" @click="ShowSearch()" icon="el-icon-search" size="mini">查询</el-button>

    <!--      <i class="el-icon-question" @click="open" style="margin-left: 10px">查看如何多条件搜索?</i>-->
<!--      <el-input v-model="searchtest1" placeholder="请输入要查询的字段的值,使用/分隔" style="width: 20%; margin-left: 10px" size="mini"></el-input>-->
<!--      <el-button type="primary" style="margin-top: 10px; margin-left: 10px" @click="ShowSearchtest()" icon="el-icon-search" size="mini">查询</el-button>-->

    <div style="margin-top: 10px;margin-bottom: 10px;">
    <el-button
        type="primary"
        class="handle-del mr10"
        @click="ShowAllSchool()"
        size="mini"
        style="width: 160px"
    >展示所有数据</el-button>
    <el-button
        type="primary"
        class="handle-del mr10"
        @click="SchoolAdd()"
        icon="el-icon-circle-plus-outline"
        size="mini"
        style="width: 160px"
    >添加学校数据</el-button>
    <el-button
        type="primary"
        class="handle-del mr10"
        @click="Export"
        icon="el-icon-download"
        size="mini"
        style="width: 160px"
    >导出</el-button>
<!--      <el-button-->
<!--          type="primary"-->
<!--          class="handle-del mr10"-->
<!--          @click="randomPassword"-->
<!--          icon="el-icon-edit"-->
<!--          size="mini"-->
<!--          style="width: 160px"-->
<!--      >生成密码</el-button>-->
<!--      <i class="el-icon-question" style="color: red">点击表格最左侧多选框，批量生成随机密码</i>-->
    </div>
<!--    </div>-->
  <el-table
      :data=this.tableData
      border
      size="mini"
      :row-style="{height:'0'}"
      :cell-style="{padding:'0px'}"
      :header-cell-style="{background:'lightblue',color:'#262626'}"
      style="width: 100%">
<!--          <el-table-column-->
<!--              type="selection"-->
<!--              width="55">-->
<!--          </el-table-column>-->
    <el-table-column
        prop="schoolcode"
        label="学校标识码"
        align="center"
        width="100">
    </el-table-column>
    <el-table-column
        prop="schoolname"
        label="学校名称"
        align="center"
        width="250">
    </el-table-column>
    <el-table-column
        prop="schoollocationname"
        label="学校地址名称"
        width="340"
        align="center"
       >
    </el-table-column>
    <el-table-column
        prop="schoollocationcode"
        label="学校地址代码"
        align="center"
        width="120">
    </el-table-column>
    <el-table-column
        prop="schoollocationtypename"
        label="学校驻地城乡类型(代码)名称"
        align="center"
        width="180"
        >
    </el-table-column>
    <el-table-column
        prop="schooltypename"
        label="学校办学类型(代码)名称"
        align="center"
        width="180">
    </el-table-column>
    <el-table-column
        prop="schoolhostname"
        label="学校举办者(代码)名称"
        align="center"
        width="180"
        >
    </el-table-column>
<!--    <el-table-column-->
<!--        prop="password"-->
<!--        label="学校密码"-->
<!--        align="center"-->
<!--        width="120">-->
<!--    </el-table-column>-->
    <el-table-column
        fixed="right"
        label="操作"
        align="center"
        width="100">
      <template slot-scope="scope">
        <el-button @click="edit(scope.row),dialogFormVisible = true" type="text" size="small">修改</el-button>
        <el-button @click="del(scope.row)" type="text" size="small">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
  <el-table
      :data=this.tableData1
      border
      hidden
      id="out-table1"
      :header-cell-style="{background:'lightblue',color:'#262626'}"
      style="width: 100%">
    <el-table-column
        prop="schoolcode"
        label="学校标识码"
        width="110">
    </el-table-column>
    <el-table-column
        prop="schoolname"
        label="学校名称"
        width="280">
    </el-table-column>
    <el-table-column
        prop="schoollocationname"
        label="学校地址名称"
        width="310">
    </el-table-column>
    <el-table-column
        prop="schoollocationcode"
        label="学校地址代码"
        width="120">
    </el-table-column>
    <el-table-column
        prop="schoollocationtypecode"
        label="学校驻地城乡类型代码"
        width="80">
    </el-table-column>
    <el-table-column
        prop="schoollocationtypename"
        label="学校驻地城乡类型名称"
        width="100">
    </el-table-column>
    <el-table-column
        prop="schooltypecode"
        label="学校办学类型代码"
        width="75">
    </el-table-column>
    <el-table-column
        prop="schooltypename"
        label="学校办学类型名称"
        width="75">
    </el-table-column>
    <el-table-column
        prop="schoolhostcode"
        label="学校举办者代码"
        width="80">
    </el-table-column>
    <el-table-column
        prop="schoolhostname"
        label="学校举办者名称"
        width="80">
    </el-table-column>

  </el-table>
<!--    @current-change 监视当前页变化-->
    <el-pagination
        background
        style="margin-top: 10px"
        layout="prev, pager, next"
        page-size="15"
        :total="total"
        v-show="isShow"
        hide-on-single-page
        @current-change="page">
    </el-pagination>
    <el-dialog :title=this.modeName :visible.sync="dialogFormVisible" :show-close=false width="950px">
      <hr style="margin-top: -30px;margin-bottom: 10px">
      <el-form :model="ruleForm" :rules="rules" :inline="true" ref="ruleForm" label-width="170px" class="demo-ruleForm">
        <el-form-item label="学校标识码" prop="schoolcode">
          <el-input style="width: 200px" v-model="ruleForm.schoolcode"></el-input>
        </el-form-item>
        <el-form-item label="学校名称" prop="schoolname">
          <el-input style="width: 230px" v-model="ruleForm.schoolname"></el-input>
        </el-form-item>
        <el-form-item label="学校地址名称" prop="schoollocationname">
          <el-input style="width: 610px;" v-model="ruleForm.schoollocationname"></el-input>
        </el-form-item>
        <el-form-item label="学校地址代码" prop="schoollocationcode">
          <el-input style="width: 610px;" v-model="ruleForm.schoollocationcode"></el-input>
        </el-form-item>
        <el-form-item label="学校驻地城乡类型代码">
          <el-select v-model="locationtypevalue" placeholder="请选择驻地城乡类型代码" @change="getLocationTypeName">
            <el-option
                v-for="item in locationtypenameoptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
<!--        <el-form-item label="学校驻地城乡类型名称" prop="schoollocationtypename">-->
<!--          <el-input v-model="ruleForm.schoollocationtypename" readonly></el-input>-->
<!--        </el-form-item>-->
        <el-form-item label="学校办学类型代码">
          <el-select v-model="typevalue" placeholder="请选择办学类型代码" @change="getTypeName">
            <el-option
                v-for="item in typenameoptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
<!--        <el-form-item label="学校办学类型名称" prop="schooltypename">-->
<!--          <el-input v-model="ruleForm.schooltypename" readonly></el-input>-->
<!--        </el-form-item>-->
        <el-form-item label="学校举办者代码">
          <el-select v-model="hostvalue" placeholder="请选择举办者代码" @change="getHostName">
            <el-option
                v-for="item in hostnameoptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
<!--        <el-form-item label="学校举办者名称" prop="schoolhostname">-->
<!--          <el-input v-model="ruleForm.schoolhostname" readonly></el-input>-->
<!--        </el-form-item>-->

<!--        <el-form-item label="学校密码" prop="password">-->
<!--          <el-input v-model="ruleForm.password" style="width: 220px;"></el-input>-->
<!--        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm('ruleForm'),allid=''">确定</el-button>
<!--        <el-button @click="resetForm('ruleForm')">重置</el-button>-->
        <el-button @click="quxiao()">取 消</el-button>
        <!--        <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>-->
      </div>
    </el-dialog>

  </div>
</template>

<script>
export default {
  methods:{
    //翻页
    page(currentPage){
      const _this=this
      this.returnPage=currentPage
      axios.get('http://localhost:8081/school/page?current='+currentPage+'&size=15').then(function (res) {
        for (let i=0;i<res.data.schoolList.length;i++){
          res.data.schoolList[i].schoolhostname='('+res.data.schoolList[i].schoolhostcode+')'+res.data.schoolList[i].schoolhostname
          res.data.schoolList[i].schooltypename='('+res.data.schoolList[i].schooltypecode+')'+res.data.schoolList[i].schooltypename
          res.data.schoolList[i].schoollocationtypename='('+res.data.schoolList[i].schoollocationtypecode+')'+res.data.schoolList[i].schoollocationtypename
        }
        // console.log(res.data)
        _this.tableData = res.data.schoolList;
        _this.total = res.data.total;
      })
    },

    // open() {
    //   this.$alert(`多条件搜索支持：学校标识码-学校名称-学校地址名称-学校地址代码-学校驻地城乡类型代码-
    //   学校办学类型代码-学校举办者代码同时模糊搜索.请在输入框中按照上述顺序依次填写需要搜索的条件的值(填写n代表不设条件,不同条件间用/分隔)
    //   多条件搜索示例：2/重庆/n/500/n/n/n 表示学校标识号中含有2,学校名称中含有重庆,学校地址代码中含有500,其余条件均不设置`, '多条件查询', {
    //     confirmButtonText: '确定',
    //     callback: action => {
    //     }
    //   });
    // },
    //刷新数据
    ShowAllSchool(){
      // const _this=this
      // axios.get('http://localhost:8081/school/page?current='+currentPage+'&size=8').then(function (res) {
      //   // console.log(res.data)
      //   _this.tableData = res.data.schoolList;
      //   _this.total = res.data.total;
      //
      // })
      location.reload();
    },
    //多条件查询
    ShowSearch(){
      this.isShow=false
      const _this=this
      if (this.search1===''){
        this.search1='all'
      }
      if (this.search2===''){
        this.search2='all'
      }
      if (this.search3===''){
        this.search3='all'
      }
      if (this.search4===''){
        this.search4='all'
      }
      if (this.search5===''){
        this.search5='all'
      }
      if (this.search6===''){
        this.search6='all'
      }
      this.searchtest1=this.search1+'/'+this.search2+'/'+this.search3+'/'+this.search4+'/'+this.search5+'/'+this.search6
      console.log(this.searchtest1)
        axios.get("http://localhost:8081/school/searchmorethanone/"+this.searchtest1).then(function (res){
          console.log(res.data)
          _this.tableData=res.data
        })
      this.search1=''
      this.search2=''
      this.search3=''
      this.search4=''
      this.search5=''
      this.search6=''
    },
    // ShowSearchtest(){
    //   this.isShow=false
    //   const _this=this
    //   // const v=this.searchtest1.replaceAll(",","/")
    //   // console.log(v)
    //   axios.get("http://localhost:8081/school/searchmorethanone/"+this.searchtest1).then(function (res){
    //     console.log(res.data)
    //     _this.tableData=res.data
    //   })
    // },
    getTypeName(){
      this.ruleForm.schooltypename=this.typenameoptions[Math.abs(this.tlen-this.typevalue-1)].label
      this.ruleForm.schooltypecode=this.typeoptions[Math.abs(this.tlen-this.typevalue-1)].label
    },
    getLocationTypeName(){
      this.ruleForm.schoollocationtypename=this.locationtypenameoptions[Math.abs(this.llen-this.locationtypevalue-1)].label
      this.ruleForm.schoollocationtypecode=this.locationtypeoptions[Math.abs(this.llen-this.locationtypevalue-1)].label
    },
    getHostName(){
      this.ruleForm.schoolhostname=this.hostnameoptions[Math.abs(this.hlen-this.hostvalue-1)].label
      this.ruleForm.schoolhostcode=this.hostoptions[Math.abs(this.hlen-this.hostvalue-1)].label
    },
    submitForm(formName) {
      const _this=this
      this.$refs[formName].validate((valid) => {
        if (valid) {
          //判断是更新还是添加
          //更新
          if  (this.allid){
            console.log(this.ruleForm)
            axios.put("http://localhost:8081/school/update",this.ruleForm).then(function (res){
              if (res.data.msg==="更新成功"){
                _this.$message({
                  message: '修改成功！',
                  type: 'success'
                });
                //添加成功后页面跳转
                // _this.$router.push('/SchoolList')
                _this.dialogFormVisible=false
                _this.page(_this.returnPage)
              }
              else{
                _this.$message({
                  message: '学校名称重复！请重新输入',
                  type: 'fail'
                });
              }
            })
          }
         else {
            //添加数据
            let code = '';
            //设置长度，这里看需求，我这里设置了4
            const codeLength = 8;
            //设置随机字符
            const random = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
            //循环codeLength 我设置的4就是循环4次
            for (let i = 0; i < codeLength; i++) {
              //设置随机数范围,这设置为0 ~ 36
              const index = Math.floor(Math.random() * 9);
              //字符串拼接 将每次随机的字符 进行拼接
              code += random[index];
            }
            axios.post("http://localhost:8081/school/save",this.ruleForm).then(function (res){
              let newInsert={username:_this.ruleForm.schoolcode,password:code,schoolname:_this.ruleForm.schoolname}
              console.log(newInsert)
              if (res.data.msg==="添加成功"){
                _this.$message({
                  message: '添加成功！',
                  type: 'success'
                  //添加成功后页面跳转
                });
                // 添加学校后 添加此学校的账号
                axios.post("http://localhost:8081/schooluser/save",newInsert).then(function (res){
                  // console.log(res.data.msg);
                  if (res.data.msg==="添加成功"){
                  }
                  else{
                    _this.$message({
                      message: '用户名重复或者学校名称不存在！请重新输入',
                      type: 'fail'
                    });
                  }
                })
                _this.dialogFormVisible=false
                _this.page(_this.returnPage)
              }
              else{
                _this.$message({
                  message: '学校名称重复！请重新输入',
                  type: 'fail'
                });
              }
            })
          }
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    //弹框取消事件
    quxiao(){
      this.dialogFormVisible = false
      this.allid=''
      this.page(this.returnPage)
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    //添加学校弹框
    SchoolAdd(){
      this.dialogFormVisible = true;
      this.modeName='添加学校数据'
      this.ruleForm={}
      this.typevalue=''
      this.locationtypevalue=''
      this.hostvalue=''
    },
    //修改某行的数据
    edit(row){
      // this.typevalue=row.schooltypecode
      // this.locationtypevalue=row.schoollocationtypecode
      // this.hostvalue=row.schoolhostcode
      //处理这三个的格式
      this.typevalue=row.schooltypename.split(')')[1]
      this.locationtypevalue=row.schoollocationtypename.split(')')[1]
      this.hostvalue=row.schoolhostname.split(')')[1]
      this.dialogFormVisible = true
      this.modeName='更新学校数据'
      this.ruleForm=row
      this.ruleForm.schooltypename=this.typevalue
      this.ruleForm.schoollocationtypename=this.locationtypevalue
      this.ruleForm.schoolhostname=this.hostvalue
      this.allid=row.id
    },
    //导出
    Export(){
      let tables = document.getElementById("out-table1");
      console.log(tables)
      let table_book = this.$XLSX.utils.table_to_book(tables);
      var table_write = this.$XLSX.write(table_book, {
        bookType: "xlsx",
        bookSST: true,
        type: "array"
      });
      try {
        this.$FileSaver.saveAs(
            new Blob([table_write], { type: "application/octet-stream" }),
            "SchoolList.xlsx"
        );
      } catch (e) {
        if (typeof console !== "undefined") console.log(e, table_write);
      }
      return table_write;
    },
    //删除某个学校的数据
    del(row){
      const d=confirm("确定删除吗？");
      if (d){
        axios.delete('http://localhost:8081/school/delete/'+row.schoolname).then(()=>{
          //删除某个学校时，也删除其账号
          axios.delete('http://localhost:8081/schooluser/delete/'+row.schoolcode).then(()=>{
          })
          alert("删除成功")
          // location.reload();
          console.log(this.total)
          if((this.total-1)% 15===0){
            this.page(this.returnPage-1)
          }
        else {
            this.page(this.returnPage)
          }
        })
      }
    },
    //处理多选框选择事件
   handleSelectionChange(val) {
      this.multipleSelection = val;
      console.log(this.multipleSelection)
    },
    //随机密码生成
    randomPassword(){
      console.log(this.multipleSelection)
      if (this.multipleSelection.length!==0){
      for (let i =0 ; i<this.multipleSelection.length;i++){
        let code = '';
        //设置长度
        const codeLength = 8;
        //设置随机字符
        const random = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
        //循环codeLength
        for (let i = 0; i < codeLength; i++) {
          //设置随机数范围,这设置为0 ~ 36
          const index = Math.floor(Math.random() * 9);
          //字符串拼接 将每次随机的字符 进行拼接
          code += random[index];
        }
        //将拼接好的字符串赋值给展示的code
        this.code = code;
        // 将选择的行的密码改成随机密码
        this.multipleSelection[i].password=this.code
        // 换传入数据库的三条字段格式
        console.log(this.multipleSelection[i])
        let stn=this.multipleSelection[i].schooltypename.split(')')[1]
        let shn=this.multipleSelection[i].schoolhostname.split(')')[1]
        let sltn=this.multipleSelection[i].schoollocationtypename.split(')')[1]
        let newMultiple=this.multipleSelection[i]

        newMultiple.schooltypename=stn
        newMultiple.schoollocationtypename=sltn
        newMultiple.schoolhostname=shn
        axios.put("http://localhost:8081/school/update",newMultiple).then((res)=>{
          console.log(res.data)
          if (res.data.msg==="更新成功"){
            this.$message({
              message: '修改成功！',
              type: 'success'
            });
            this.page(this.returnPage)
          }
          else{
            this.$message({
              message: '学校名称重复！请重新输入',
              type: 'fail'
            });
          }
        })

      }
      }
      else {
        alert('未选择')
      }
    }

  },

  data(){
    return {
      code:'',
      isShow:true,
      search1:'',
      search2:'',
      search3:'',
      search4:'',
      search5:'',
      search6:'',
      allid:'',
      mode:'',
      modeName:'',
      returnPage:'',
      searchtest1:'',
      options1: [],
      options2: [],
      options3: [],
      value: '',
      valuetest1: '',
      valuetest2: '',
      total:null,
      tableData: null,
      tableData1: null,
      dataList: [],
      fileList: [],
      multipleSelection: [],
      query: {"page":0, "size":18, count:0},
      column: [
        {label: "学校标识码", prop: "schoolcode", type: "integer"},
        {label: "学校名称", prop: "schoolname", type: "string"},
        {label: "学校地址名称", prop: "schoollocationname", type: "string"},
        {label: "学校地址代码", prop: "schoollocationcode", type: "integer"},
        {label: "学校驻地城乡类型代码", prop: "schoollocationtypecode", type: "string"},
        {label: "学校驻地城乡类型名称", prop: "schoollocationtypename", type: "string"},
        {label: "学校办学类型代码", prop: "schooltypecode", type: "integer"},
        {label: "学校办学类型名称", prop: "schooltypename", type: "integer"},
        {label: "学校举办者代码", prop: "schoolhostcode", type: "integer"},
        {label: "学校举办者名称", prop: "schoolhostname", type: "integer"},
      ],
      editForm: {},
      editVisible: false,
      currentIndex: null,
      dialogTableVisible: false,
      dialogFormVisible: false,
      formLabelWidth: '120px',
      ruleForm: {
        schoolcode: '',
        schoolname: '',
        schoollocationname: '',
        schoollocationcode: '',
        schoollocationtypecode: '',
        schoollocationtypename: '',
        schooltypecode: '',
        schooltypename: '',
        schoolhostcode: '',
        schoolhostname:'',
        password:''
      },
      rules: {
        id: [
          { required: true, message: '请填写编号 注意与已存在的编号不要重复', trigger: 'blur' }
        ],
        schoolcode: [
          { required: true, message: '请填写学校标识码', trigger: 'blur' }
        ],
        schoolname: [
          { required: true, message: '请填写学校名称', trigger:'blur' }
        ],
        schoollocationname: [
          { required: true, message: '请填写学校地址名称', trigger: 'blur' }
        ],
        schoollocationcode: [
          { required: true, message: '请填写学校地址代码', trigger: 'blur' }
        ],
        schoollocationtypecode: [
          { required: true, message: '请填写学校驻地城乡类型，没有则填无', trigger: 'blur' }
        ],
        schoollocationtypename: [
          { required: true, message: '请在下拉栏选择学校驻地城乡类型', trigger: 'blur' }
        ],
        schooltypecode: [
          { required: true, message: '请填写学校办学类型，没有则填无', trigger: 'blur' }
        ],
        schooltypename: [
          { required: true, message: '请在下拉栏选择学校办学类型代码', trigger: 'blur' }
        ],
        schoolhostcode: [
          { required: true, message: '请填写学校举办者代码，没有则填无', trigger: 'blur' }
        ],
        schoolhostname: [
          { required: true, message: '请在下拉栏选择学校举办者代码', trigger: 'blur' }
        ],
        password: [
          { required: true, message: '请填写密码', trigger: 'blur' }
        ],
      },
      typevalue: '',
      typeoptions: [],
      typenameoptions: [],
      hostvalue:'',
      hostoptions:[],
      hostnameoptions:[],
      locationtypevalue:'',
      locationtypeoptions:[],
      locationtypenameoptions:[],
      tlen:'',
      llen:'',
      hlen:'',
      // originSchoolHostName:[],
      // originSchoolTypeName:[],
      // originSchoolLocationTypeName:[],
    }
  },

  created() {
    this.isShow=true;
    const _this=this
    let typelen=0
    let locationtypelen=0
    let hostlen=0
    const a=localStorage.getItem("access-admin")
    if(a){
      axios.get('http://localhost:8081/school/page?current=1&size=15').then(function (res){
          for (let i=0;i<res.data.schoolList.length;i++){
            res.data.schoolList[i].schoolhostname='('+res.data.schoolList[i].schoolhostcode+')'+res.data.schoolList[i].schoolhostname
            res.data.schoolList[i].schooltypename='('+res.data.schoolList[i].schooltypecode+')'+res.data.schoolList[i].schooltypename
            res.data.schoolList[i].schoollocationtypename='('+res.data.schoolList[i].schoollocationtypecode+')'+res.data.schoolList[i].schoollocationtypename
          }
        _this.returnPage=res.data.current;
        _this.tableData=res.data.schoolList;
        _this.total=res.data.total;
      })
      axios.get('http://localhost:8081/school/findAll').then(function (res){
        _this.tableData1=res.data
      })
      axios.get("http://localhost:8081/schooltype/findAll").then(function (res){
        typelen=res.data.length;
        _this.tlen=res.data.length
        while(typelen){
          typelen--;
          _this.typeoptions.push({value:typelen,label:res.data[typelen].schooltypecode})
          _this.typenameoptions.push({value:typelen,label:res.data[typelen].schooltypename})
        }

      })
      axios.get("http://localhost:8081/schoollocationtype/findAll").then(function (res){
        locationtypelen=res.data.length;
        _this.llen=res.data.length;
        while(locationtypelen){
          locationtypelen--;
          _this.locationtypeoptions.push({value:locationtypelen,label:res.data[locationtypelen].schoollocationtypecode})
          _this.locationtypenameoptions.push({value:locationtypelen,label:res.data[locationtypelen].schoollocationtypename})
        }
      })
      axios.get("http://localhost:8081/schoolhost/findAll").then(function (res){
        hostlen=res.data.length;
        _this.hlen=res.data.length;
        while(hostlen){
          hostlen--;
          _this.hostoptions.push({value:hostlen,label:res.data[hostlen].schoolhostcode})
          _this.hostnameoptions.push({value:hostlen,label:res.data[hostlen].schoolhostname})
        }
      })
    }
    else{
      this.$alert('未登录','提示',{
        confirmButtonText:'确定'
      }).then((res)=>{
        this.$router.replace({path:'/login'})
      })
    }

  }
}
</script>
<style scoped>
.el-tooltip__popper {
  max-width: 20%;
}
.el-table__header{
 height: 20px;
}

</style>
